import { useMapCity } from '@/stores/mapCity';
const $mapcity = useMapCity()
//对存储到localStorage的数据进行存储
function localStorageStoreByCityName({cityName,recentCities}){
    $mapcity.setCurrentCity(cityName)
    localStorage.setItem('currentCity', $mapcity.currentCity)
    //有重复不在添加，并且将重复的删除，将点击元素放到最前面
    if (recentCities.value.includes(cityName)) {
      recentCities.value.splice(recentCities.value.indexOf(cityName), 1)
    }
    //保留三个城市
    recentCities.value.unshift(cityName)
    recentCities.value = recentCities.value.slice(0, 3)
    // console.log(recentCities.value,"2")
    return recentCities.value
}
export{localStorageStoreByCityName}
